<template>
  <div class="deposit">
    <div class="main">
      <div class="main-top">
        <div class="deposit-left">提现到微信账户</div>
        <div class="deposit-right">
          <div class="deposit-top">
            <img src="@/assets/weixi.png" alt="" />
            123456789
          </div>
          <div class="deposit-descs">公司将在48小时内响应你的提现请求</div>
        </div>
      </div>
      <div class="main-center">
        <div class="title">提现金额</div>
        <div class="card-price">
          <div class="price-ren">¥</div>
          <van-field v-model="value" placeholder="1000" />
        </div>
      </div>
      <div class="main-desc">
        <div class="tip-desc">当前可提现余额{{ tPrice }}元</div>
        <div class="full" @click="kitingClick">全部提现</div>
      </div>
      <div
        class="main-button"
        :class="isActive ? 't-actives' : ''"
        @click="payClick"
      >
        提现
      </div>
    </div>
    <div class="main-notes">
      <div class="container">
        <p>提现备注</p>
        <div class="inputs">
          <van-field v-model="notes" placeholder="" />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { Toast } from 'vant'
export default {
  name: 'deposit',
  data() {
    return {
      value: '',
      notes: '',
      tPrice: 4000,
      tActive: false,
    }
  },
  methods: {
    payClick() {
      // wx.config({
      //   debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
      //   appId: options.appId, // 必填，公众号的唯一标识
      //   timestamp: options.timestamp, // 必填，生成签名的时间戳
      //   nonceStr: options.noncestr, // 必填，生成签名的随机串
      //   signature: options.signature, // 必填，签名
      //   jsApiList: ['chooseImage', 'updateAppMessageShareData'], // 必填，需要使用的JS接口列表
      // })
      if (this.isActive) {
        if (this.value > this.tPrice) {
          Toast('可提现余额不足')
        } else {
          // Toast('正在支付')
          const toast = Toast.loading({
            duration: 0, // 持续展示 toast
            forbidClick: true,
            message: '提现中',
          })

          let second = 1
          const timer = setInterval(() => {
            second--
            if (second) {
              toast.message = `提现中`
            } else {
              clearInterval(timer)
              // 手动清除 Toast
              Toast.clear()
              this.$router.push('/apply')
            }
          }, 1000)
          

        }
      } else {
        Toast('请选择金额')
      }
    },
    kitingClick() {
      if (this.tPrice > 0) {
        this.value = this.tPrice
        // this.tActive = true
      } else {
        Toast('可提现余额不足')
      }
    },
  },
  computed: {
    isActive() {
      if (this.value > 0) {
        return true
      } else {
        return false
      }
    },
  },
}
</script>

<style lang="scss" scoped>
.deposit {
  font-size: 14px;
  padding: 12px;
  background: #f7f6fb;
  height: 100vh;
  //overflow-y: auto;
}
.main {
  width: 351px;
  height: 294px;
  background: #ffffff;
  border-radius: 8px;
  padding: 20px 16px 16px;
  margin-bottom: 12px;
  .main-top {
    display: flex;
    padding-bottom: 16px;
    border-bottom: 1px solid #f7f6fb;
    .deposit-left {
      margin-right: 10px;
    }
    .deposit-top {
      display: flex;
      align-items: center;
      img {
        width: 24px;
        height: 24px;
      }
    }
    .deposit-descs {
      color: #afabb7;
      font-size: 12px;

      font-weight: 400;
    }
  }
}
.main-center {
  margin: 20px 0 16px;
  .card-price {
    margin-top: 13px;
    display: flex;
    border-bottom: 1px solid #f7f6fb;
    .price-ren {
      width: 17px;
      height: 40px;
      font-size: 28px;
      font-weight: 600;
      color: #1f0d44;
      line-height: 40px;
      margin-right: 5px;
    }
  }
}
.main-desc {
  display: flex;
  color: #afabb7;
  font-size: 12px;
  margin-bottom: 20px;
  font-weight: 400;
  .full {
    margin-left: 8px;
    color: #1677ff;
  }
}
.main-button {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 319px;
  height: 40px;
  background: #dbd9de;
  border-radius: 20px;

  font-weight: 500;
  color: #665e75;
}
.main-notes {
  width: 351px;
  height: 104px;
  background: #ffffff;
  border-radius: 8px;
  padding: 16px;
}
.inputs {
  margin-top: 8px;
  ::v-deep .van-field__body {
    width: 319px;
    height: 44px;
    background: #f7f6fb;
    border-radius: 8px;
    input {
      height: 100%;
    }
  }
}
.t-actives {
  background: linear-gradient(135deg, #2389ff 0%, #1852f9 100%);
  box-shadow: 0px 4px 12px 0px rgba(31, 13, 68, 0.04);
  border-radius: 20px;
  color: #fff;
}
::v-deep .van-cell {
  padding: 0;

  // border-bottom: 1px solid #f7f6fb;
}
::v-deep .van-cell__value {
  display: flex;
  align-items: center;
}
.main {
  ::v-deep .van-field__body {
    height: 100%;
    input {
      height: 100%;
      font-size: 24px;
    }
  }
}
</style>